package com.humanresource.action.clerkrecord;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.humanresource.domain.Result;
import com.humanresource.domain.po.clerkrecord.Clerkbaseinfo;
import com.humanresource.service.clerkrecord.ClerkBaseInfoService;
import com.humanresource.utils.ResultUtil;

@Controller
@RequestMapping("/humanresource")
public class LoginController {

	@Autowired
	private ClerkBaseInfoService clerkBaseInfoService;

	@RequestMapping(value = "/login", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@ResponseBody
	public Result login(HttpServletRequest request) {

		Clerkbaseinfo loginclerk = this.clerkBaseInfoService.login(
				request.getParameter("clerkname"),// 获得页面传过来的登录员工姓名
				request.getParameter("clerkpassword"));// 获得页面传过来的员工登录密码
		if (loginclerk == null) {
			return ResultUtil.error(404, "用户名或密码错误");
		}
		return ResultUtil.success(loginclerk);
	}
}
